package com.elong.spring.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class SimulatorProxy implements Simulator{

    //处理器对象
    protected InvocationHandler handler;
    
    @Override
    public short simulate(int arg1, long arg2, String arg3) {
	//获取simulate方法的method对象
	Method method = null;
	try {
	    method = Simulator.class.getMethod("simulate", new Class[] {int.class, long.class, String.class});
	} catch (Exception e) {
	    // TODO: handle exception
	}
	//第二部 调用handler的invoke方法分派转发方法调用
	Object r = null;
	try{
	    r = handler.invoke(this, method,  new Object[] {new Integer(arg1), new Long(arg2), arg3});
	}catch(Throwable e){
	    
	}
	return ((Short)r).shortValue();
    }

}
